package com.doctcloud.hisinfo.api.factory;

import com.doctcloud.common.core.domain.R;
import com.doctcloud.hisinfo.api.RemoteHisCommonService;
import com.doctcloud.hisinfo.histable.domain.comm.DeptDictDo;
import com.doctcloud.hisinfo.histable.domain.comm.PriceListDo;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
public class RemoteHisCommFallbackFactory implements FallbackFactory<RemoteHisCommonService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteHisCommFallbackFactory.class);
    @Override
    public RemoteHisCommonService create(Throwable cause) {
        log.error("HIS公共服务调用失败:{}", cause.getMessage());
        return new RemoteHisCommonService()
        {
            @Override
            public R<List<DeptDictDo>> deptListByDB() {
                return R.fail("获取科室列表失败:" + cause.getMessage());
            }

            @Override
            public R<DeptDictDo> dbqueryDeptByDB(String deptCode) {
                return R.fail("获取科室失败:" + cause.getMessage());
            }

            @Override
            public R<List<PriceListDo>> dbPriceListAll() {
                return R.fail("获取价表失败:" + cause.getMessage());
            }

        };
    }
}
